package com.service;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class TimeTaskService {

    @Value("${upload.tmp.dir}")
    private String tmp;

    /**
     * 定时删除临时目录
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void clearTmpDir()
    {
        File file = new File(tmp);
        File[] files = file.listFiles();
        for (File f:files)
        {
            if (f.isFile())
            {
                f.delete();
            }
        }
    }
}
